package com.ssy.system.controller;

import com.ssy.bus.pojo.Purchase;
import com.ssy.bus.service.IPurchaseService;
import com.ssy.common.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ssy
 * <p>
 * 后端路由控制
 */
@Controller
@RequestMapping("system")
public class SystemController {

    @Autowired
    private IPurchaseService purchaseService;

    /**
     * 跳转登录页面
     *
     * @return path
     */
    @RequestMapping(value = {"/", "toLogin"})
    public String toLogin() {
        return "index.html";
    }

    /**
     * 跳转首页
     *
     * @return path
     */
    @RequestMapping("/toIndex")
    public String toIndex() {
        return "index";
    }

    @RequestMapping("/toIndex2")
    public String toIndex2(){
        return "view/error/403";
    }

    /**
     * 跳转科室管理
     *
     * @return path
     */
    @RequestMapping("/toDepartment")
    public String toDepartment() {
        return "view/bus/department/department";
    }

    /**
     * 跳转字典管理
     *
     * @return path
     */
    @RequestMapping("/toDictionaries")
    public String toDictionaries() {
        return "view/system/Dictionaries/dictionaries";
    }

    /**
     * 跳转字典管理
     *
     * @return path
     */
    @RequestMapping("/toUser")
    public String toUser() {
        return "view/system/user/user";
    }

    /**
     * 跳转角色管理
     *
     * @return path
     */
    @RequestMapping("/toRole")
    public String toRole() {
        return "view/system/role/role";
    }

    /**
     * 跳转公告管理
     *
     * @return path
     */
    @RequestMapping("/toNotice")
    public String toNotice() {
        return "view/system/notice/notice";
    }

    /**
     * 跳转检查费用管理
     *
     * @return path
     */
    @RequestMapping("/toInspect")
    public String toInspect() {
        return "view/system/inspect/inspect";
    }

    /**
     * 跳转挂号费用管理
     *
     * @return path
     */
    @RequestMapping("/toRegister")
    public String toRegister() {
        return "view/system/register/register";
    }

    /**
     * 跳转生产厂家管理
     *
     * @return path
     */
    @RequestMapping("/toProduction")
    public String toProduction() {
        return "view/bus/production/production";
    }

    /**
     * 跳转药品信息管理
     *
     * @return path
     */
    @RequestMapping("/toDrugInfo")
    public String toDrugInfo() {
        return "view/bus/drugInfo/drugInfo";
    }

    /**
     * 跳转供应商管理
     *
     * @return path
     */
    @RequestMapping("/toSupplier")
    public String toSupplier() {
        return "view/bus/supplier/supplier";
    }

    /**
     * 跳转采购入库列表
     *
     * @return path
     */
    @RequestMapping("/toPurchase")
    public String toPurchase() {
        return "view/bus/purchase/purchase";
    }

    /**
     * 跳转新增采购入库
     *
     * @return path
     */
    @RequestMapping("/toMake")
    public String toMake() {
        return "view/bus/purchase/make";
    }

    /**
     * 跳转修改采购入库
     *
     * @return path
     */
    @RequestMapping("/toUpdateMake/{id}")
    public String toUpdateMake(@PathVariable String id, Model model) {
        Map<String, Object> map = new HashMap<>();
        Purchase purchase = this.purchaseService.getById(id);
        map.put("id", id);
        map.put("operation", purchase.getOperation());
        map.put("supplierId", purchase.getSupplierId());
        map.put("price", purchase.getPrice());
        map.put("state", "" + purchase.getState());
        model.addAllAttributes(map);
        return "view/bus/purchase/updateMake";
    }

    /**
     * 跳转采购入库审核管理
     *
     * @return path
     */
    @RequestMapping("/toExamine")
    public String toExamine() {
        return "view/bus/housExamine/housExamine";
    }

    /**
     * 跳转库存查询
     *
     * @return path
     */
    @RequestMapping("/toStock")
    public String toStock() {
        return "view/bus/drugInfo/stock";
    }

    /**
     * 跳转挂号列表
     *
     * @return path
     */
    @RequestMapping("/toOutpatient")
    public String toOutpatient() {
        return "view/bus/outpatient/outpatient";
    }

    /**
     * 跳转患者库列表
     *
     * @return path
     */
    @RequestMapping("/toPatient")
    public String toPatient() {
        return "view/bus/patient/patient";
    }

    /**
     * 跳转门诊挂号
     *
     * @return path
     */
    @RequestMapping("/toSection")
    public String toSection() {
        return "view/bus/section/section";
    }

    /**
     * 跳转新开就诊
     *
     * @return path
     */
    @RequestMapping("/toSeeDoctor")
    public String toSeeDoctor() {
        return "view/bus/seeDoctor/seeDoctor";
    }

    /**
     * 跳转新开就诊
     *
     * @return path
     */
    @RequestMapping("/toCharge")
    public String toCharge() {
        return "view/bus/charge/charge";
    }

    /**
     * 跳转收费查询
     *
     * @return path
     */
    @RequestMapping("/toChargeQuery")
    public String toChargeQuery() {
        return "view/bus/charge/chargeQuery";
    }

    /**
     * 跳转处方发药
     *
     * @return path
     */
    @RequestMapping("/toDispensing")
    public String toDispensing() {
        return "view/bus/charge/dispensing";
    }

    /**
     * 跳转菜单管理
     *
     * @return path
     */
    @RequestMapping("/toMenuManage")
    public String toMenuManage() {
        return "view/system/menu/menu";
    }

    /**
     * 跳转菜单管理
     *
     * @return path
     */
    @RequestMapping("/toPermission")
    public String toPermission() {
        return "view/system/permission/permission";
    }

    /**
     * 跳转日志管理页面
     *
     * @return path
     */
    @RequestMapping("/toLog")
    public String toLog() {
        return "view/system/log/log";
    }


}
